package uutalk.netcloud.talk.app.di;

import android.app.Application;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import okhttp3.CookieJar;
import okhttp3.Interceptor;
import uutalk.netcloud.talk.EventBusIndex;
import uutalk.netcloud.talk.base.config.EventBusConfig;
import uutalk.netcloud.talk.base.config.HttpClientConfig;
import uutalk.netcloud.talk.base.provider.cookie.OkHttpCookieJar;


/**
 * Created by hujie on 16/6/18.
 */
@Module
public class ProviderConfigModule {



    @Singleton
    @Provides
    CookieJar providerCoolkieJar(Application application) {
        return new OkHttpCookieJar(application);
    }


    @Singleton
    @Provides
    HttpClientConfig provideHttpClientConfig(CookieJar cookieJar, Interceptor interceptor) {
        HttpClientConfig config = new HttpClientConfig();
        config.setConnectTimeout(3 * 60);
        config.setReadTimeout(3 * 60);
        config.setWriteTimeout(5 * 60);
        config.setRetryOnConnectionFailure(true);
        config.setCookieJar(cookieJar);
        config.setInterceptor(interceptor);

        return config;
    }



    @Singleton
    @Provides
    EventBusConfig provideEventBusConfig() {
        EventBusConfig config = new EventBusConfig();
        config.setInfoIndex(new EventBusIndex());
        return config;
    }


}
